import { AxiosError, AxiosRequestHeaders } from 'axios';

// 请求入参
export interface IFetchOption {
    url: string;
    data?: unknown;
    headers?: AxiosRequestHeaders;
    configs?: {
        withCredentials?: boolean;
        params?: unknown; // 针对 post 请求时通过 url 传参的情况
    };
}

// 响应结果
export interface IResponseResult<T> {
    code: number;
    success: boolean;
    data: T | null;
    errMsg: string;
}

// 网络请求、响应错误
export interface IFetchError {
    error: AxiosError;
    type: 'request' | 'response';
}

// 请求方法
export type TFetchMethod = 'get' | 'delete' | 'post' | 'put';
